<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>平台管理系统</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" href="/layuiadmin/layui/css/layui.css" media="all">
	<link rel="stylesheet" href="/layuiadmin/style/admin.css" media="all">
	<link rel="stylesheet" href="/css/plat-style.css" media="all">
	<style>
		thead tr th{text-align: center!important;font-weight: bold!important;}
		tr td{text-align: center!important;}
		.layui-table img {
			width: auto;
			height: auto;
			max-width: 100% !important;
			max-height: 100%;
		}
		.layui-table a img {
			width: auto;
			height: auto;
			max-width: 100% !important;
			max-height: 100%;
		}
		.operation button{
			margin-bottom: 5px;
		}
	</style>
</head>
<body>
<div class="layui-fluid">
	<div class="layui-row layui-col-space15">
		<div class="layui-col-md12">
			<div class="layui-card">
				<div class="layui-card-body layui-form">
					<%-- 查询条件设置 --%>
					<div class="layui-container layui-form-item" style="padding-bottom: 50px">
						<div class="layui-col-md12">
							<div class="layui-col-md4">
								<div class="layui-col-sm3" style="line-height: 38px">订单编号：</div>
								<div class="layui-col-sm7">
									<input type="text" name="orderCode" class="layui-input" value="${refund.orderCode}" placeholder="订单编号">
								</div>
							</div>
							<div class="layui-col-md4">
								<div class="layui-col-sm3" style="line-height: 38px">状态：</div>
								<div class="layui-col-sm7">
									<select name="status" class="select">
										<option value="">请选择</option>
										<option value="1" ${refund.status == 1?'selected="selected"':'' }>申请中</option>
										<option value="2" ${refund.status == 2?'selected="selected"':'' }>退款成功</option>
										<option value="3" ${refund.status == 3?'selected="selected"':'' }>退款驳回</option>
										<option value="4" ${refund.status == 4?'selected="selected"':'' }>退款取消</option>
									</select>
								</div>
							</div>
							<div class="layui-col-md4">
								<div class="layui-col-sm3">
									<button class="layui-btn layuiadmin-btn-list" lay-submit
											lay-filter="LAY-app-contlist-search">查询</button>
								</div>
							</div>
						</div>
					</div>
					<div class="layui-col-md12"><hr></div>
					<%-- 数据展示 --%>
					<table class="layui-table" id="table" lay-filter="table">
						
					</table>
					<script type="text/html" id="toolbar">
						<div class="layui-btn-container">
							<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看详情</a>
						</div>
					</script>
				</div>
			</div>
		</div>
	</div>
</div>

<script src="/layuiadmin/layui/layui.js"></script>
<script src="/js/common.js"></script>
<script>
	layui.config({
		base: '/layuiadmin/' //静态资源所在路径
	}).extend({
		index: 'lib/index' //主入口模块
	}).use(['index','form', 'table'], function(){
		var $ = layui.$,layer = layui.layer,form = layui.form,element = layui.element, table = layui.table;
		form.render('select');
		element.render();

		table.render({
			elem : '.layui-table',
			url : '/order/queryRefundList',
			page:true,
			request: {
				pageName: 'current', //页码的参数名称，默认：page
				limitName: 'size' //每页数据量的参数名，默认：limit
			},
			cols : [[ 
				{field : 'orderCode', title:'订单编号', minWidth:200},
				{field : 'refundCode', title:'退款编号', minWidth:200},
				{field : 'refundMoney', title:'退款金额', width:100},
				{field : 'applyType', title:'退款方式', width:100,
					templet : function(row){
						var applyType = row.applyType;
						if (applyType == 1) {
							return "仅退款";
						} else if (applyType == 2) {
							return "退款退货";
						}
					}	
				},
				{field : 'createTime', title : '申请时间', minWidth:150,
					templet : function(row){
						return createTime(row.createTime);
					}	
				},
				{field : 'status', title : '状态', width:100,
					templet : function(row){
						var status = row.status;
						if (status == 1) {
							return "申请中";
						} else if (status == 2) {
							return "退款成功";
						} else if (status == 3) {
							return "退款驳回";
						} else if (status == 4) {
							return "退款取消";
						}
					}	
				},
				{field : 'checkTime', title : '操作时间', width:150,
					templet : function(row){
						return createTime(row.createTime);
					}	
				},
				{title : '操作', templet:'#toolbar'}
			]],
			skin : "row",
			even: true,
			size:"lg"
		});
		
		//监听搜索
	    form.on('submit(LAY-app-contlist-search)', function(data){
	      var field = data.field;
	      //执行重载
	      table.reload('table', {
	        where: field
	      });
	    });
		
	  	//监听事件
		table.on('tool(table)', function(obj){
			var data = obj.data; //获得当前行数据
			var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
			var tr = obj.tr; //获得当前行 tr 的DOM对象
			if (layEvent === 'detail') {// 订单详情
				window.location.href = "/order/refundDetail?refundId="+data.id;
			}
		});		
		
	});
</script>
</body>
</html>